<template>
  <div class="content_page">
    <up-input
      placeholder="请输入内容"
      border="bottom"
      v-model="nickname"
      style="width: 100%"
    ></up-input>
    <div class="submit_btn" @click="toSave">保存</div>
  </div>
</template>
<script lang="ts" setup>
import { onLoad } from "@dcloudio/uni-app";
import { editInfo } from "@/api/myInfo/myInfo.ts";
import type { resInfo } from "@/api/myInfo/typs.ts";
import { ref } from "vue";
const nickname = ref<string>("");
const toSave = () => {
  editInfo({
    nickname: nickname.value,
  })
    .then((res: resInfo) => {
      if (res.resultStatus) {
        uni.showToast({
          title: "操作成功",
          icon: "none",
        });
        uni.navigateBack({
          delta: 1,
        });
      } else {
        uni.showToast({
          title: res.errorMessage,
          icon: "none",
        });
      }
    })
    .catch((err: any) => {
      uni.showToast({
        title: "服务器异常",
        icon: "none",
      });
    });
};
onLoad((options) => {
  console.log(options);
  if (options) {
    nickname.value = options.nickname;
  }
});
</script>
<style lang="scss" scoped>
.content_page {
  background-color: #fff;
  padding: 32rpx;

  .submit_btn {
    height: 88rpx;
    background: linear-gradient(90deg, #00a67e, #006d56);
    font-size: 36rpx;
    line-height: 88rpx;
    color: #fff;
    text-align: center;
    border-radius: 16rpx;
    margin: 70rpx auto;
  }
}
</style>
